//import java.util.Scanner;
//
//public class Main {
//    public static void main(String[] args) {
//        String str = new Scanner(System.in).nextLine();
//        StringBuffer ret = new StringBuffer();
//        for(int i = str.length()-1; i>=0; i--) {
//            ret.append(str.charAt(i));
//        }
//        System.out.println(ret);
//    }
//}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();
        int len = 0;
        int n = str1.length();
        for(int i =0 ; i<n; i++) {
            for(int j = i+1; j<n; j++) {
                String tmp = str1.substring(i,j+1);
                if(str2.contains(tmp)) {
                    len = Math.max(len, j-i+1);
                }
            }
        }
        System.out.println(len);
    }
}
